package cn.iocoder.yudao.module.crm.service.tasktype;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.controller.admin.tasktype.vo.TaskTypePageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.tasktype.vo.TaskTypeSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.tasktype.vo.tasktypeapprover.TaskTypeApproverDetail;
import cn.iocoder.yudao.module.crm.dal.dataobject.tasktype.TaskTypeApproverDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.tasktype.TaskTypeDO;
import cn.iocoder.yudao.module.crm.dal.mysql.tasktype.TaskTypeApproverMapper;
import cn.iocoder.yudao.module.crm.dal.mysql.tasktype.TaskTypeMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.TASK_TYPE_NOT_EXISTS;

/**
 * CRM 任务单类型审批人关联 Service 实现类
 *
 * @author 广州氪量
 */
@Service
@Validated
public class TaskTypeApproverServiceImpl implements TaskTypeApproverService {
    @Resource
    private TaskTypeApproverMapper taskTypeApproverMapper;
    @Override
    public List<TaskTypeApproverDetail> getByTaskTypeId(Long id) {
        List<TaskTypeApproverDO> taskTypeApproverDOS = taskTypeApproverMapper.getByTaskTypeId(id);
        return taskTypeApproverDOS.stream()
                .map(TaskTypeApproverDetail::toDetail)
                .filter(Objects::nonNull)
                .collect(Collectors.toList());
    }
}